<?php session_start();
	  		require_once('../includes/user.php');
	  		$user=new User();
			$date=date('Y-m-d');
	  		if($_SESSION['role']==8)
			{
				$set_quiz_res=$user->query("select * from quiz_names where result=0 ORDER BY to_date");
			}
			else if($_SESSION['role']==2)
			{
				$set_quiz_res=$user->query("select * from quiz_names where result=0 AND profile_id='$_SESSION[id]' ORDER BY to_date ");
			}
 ?>
<table width="675" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="663" align="left" valign="middle"><div class="Innerheading" id="Innerheading">Quiz</div></td>
  </tr>
  <tr>
    <td><div class="InnerDarkbox" id="InnerDarkbox">
      <table width="633" height="72" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
                <td colspan="8" align="right" valign="middle" class="head"><input type="image" src="img/buttons/b_tblops.png" alt="drop quiz" onclick="load_add_quiz()" />
                <span class="smartlink" onclick="load_add_quiz()">Setup Quiz</span></td>
                <td colspan="2" align="right" valign="middle" class="head"><input type="image" src="img/buttons/b_browse.png" alt="results" onclick="load_quiz_result()" />
                <span class="smartlink" onclick="load_quiz_result()">Results</span></td>
          </tr>
              <?php if(mysql_num_rows($set_quiz_res)>0){ ?>
              <tr>
                <td colspan="10" align="center" valign="middle" class="head">&nbsp;</td>
              </tr>
              <tr>
          <td align="center" valign="middle" class="head">Quiz name</td>
          <td align="center" valign="middle" class="head">Start date</td>
          <td align="center" valign="middle" class="head">End Date</td>
          <td align="center" valign="middle" class="head">Duration</td>
          <td align="left" valign="middle" class="head">Ques in QB</td>
          <td align="right" valign="middle" class="head"> Ques to ask</td>
          <td colspan="3" align="center" valign="middle" class="head">Settings</td>
          <td align="center" valign="middle" class="head">Upload By</td>
          </tr>
      <?php 
			while($set_quiz_row=mysql_fetch_array($set_quiz_res))
			{
	  ?>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td colspan="6">&nbsp;</td>
        </tr>
        <tr>
          <td width="88" align="center" valign="middle"><?php echo $set_quiz_row['quiz_name']; ?></td>
          <td width="73" align="center" valign="middle"><?php 
	$f_da=explode("-",$set_quiz_row['from_date']);
	echo $f_da[2].'/'.$f_da[1].'/'.$f_da[0]; ?>		  </td>
          <td width="83" align="center" valign="middle"><?php 
	$t_da=explode("-",$set_quiz_row['to_date']);
	echo $t_da[2].'/'.$t_da[1].'/'.$t_da[0]; ?></td>
          <td width="63" align="center" valign="middle"><?php
		  	if($set_quiz_row['duration']!='Nill')
		  	{
		   		echo $set_quiz_row['duration'];
		   	}
		   	else
		   	{
				echo 'Unlimited';
		   	}  
			?></td>
          <td width="78" align="center" valign="middle"><?php echo $user->recCount('quiz_question_bank',"test_id='$set_quiz_row[quiz_id]'"); ?></td>
          <td width="77" align="center" valign="middle"><?php echo $set_quiz_row['no_of_ques']; ?></td>
          <td width="33" align="center" valign="middle">
          <?php if($set_quiz_row['from_date']>$date){ ?>
          <input type="image" src="img/buttons/b_docs.png" alt="upload questions" onclick="upload_question(
		  <?php echo $set_quiz_row['quiz_id'].','.$set_quiz_row['quiz_type'].",'".$set_quiz_row['quiz_name']."'"; ?> )" />
          <?php } ?></td>
          <td width="33" align="center" valign="middle">
          <?php if($set_quiz_row['from_date']>$date){ ?>
          <input type="image" src="img/buttons/b_edit.png" alt="edit quiz" onclick="edit_quiz(<?php echo $set_quiz_row['quiz_id']; ?>)" />
          <?php }
		  else{ ?>
          <input type="image" src="img/buttons/b_props.png" onclick="getResults(<?php echo $set_quiz_row['quiz_id'];  ?>)" />
          <?php
		  	} 
		  ?>
          </td>
          <td width="33" align="center" valign="middle">
          <?php if($set_quiz_row['from_date']>$date){ ?>
          <input type="image" src="img/buttons/b_drop.png" alt="drop quiz" onclick="deleteQuiz(<?php echo $set_quiz_row['quiz_id']; ?>)" />
          <?php } ?>
          </td>
          <td width="72" align="center" valign="middle">
		  <?php $pro_row=$user->getUserProfile($set_quiz_row['profile_id']);
		  		echo $pro_row['userid']; ?></td>
        </tr>
        <?php
			}
		?>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td colspan="6">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="10" align="right" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            
            <tr>
              <td height="21" colspan="6" align="left" valign="middle">&nbsp;</td>
              </tr>
            <tr>
              <td width="16%" height="21" align="center" valign="middle"><img src="img/buttons/b_docs.png" width="16" height="16" /> Upload Ques</td>
              <td width="15%" align="center" valign="middle"><img src="img/buttons/b_edit.png" width="16" height="16" /> Edit Quiz</td>
              <td width="17%" align="center" valign="middle"><img src="img/buttons/b_drop.png" width="16" height="16" /> Delete Quiz</td>
              <td width="17%" align="center" valign="middle"><img src="img/buttons/b_tblops.png" width="16" height="16" /> Setup Quiz</td>
              <td width="18%" align="center" valign="middle"><img src="img/buttons/b_browse.png" width="16" height="16" /> Quiz Results</td>
              <td width="17%" align="center" valign="middle"><img src="img/buttons/b_props.png" width="16" height="16" /> Get Result</td>
            </tr>
           <?php }else{ ?>
           <tr>
           		 <td colspan="6" align="center" valign="middle">&nbsp;There is no other upcoming scheduled quizes!!!</td>
          		</tr>
           <?php } ?>
          </table>          </td>
          </tr>
      </table>
    </div></td>
  </tr>
</table>
